package com.hqyj.ctxp.controller;


import com.hqyj.ctxp.pojo.Category;
import com.hqyj.ctxp.service.CategoryService;
import com.hqyj.ctxp.utils.ResultInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService ;

    //展示商品种类信息
    @PostMapping("/selectCategoryAll")
    public ResultInfo selectCategoryAll(@RequestBody Category Category){
        return categoryService.selectCategoryAll(Category);
    }

    @GetMapping("/selectCategoryAll")
    public ResultInfo selectCategoryAll(){
        ResultInfo resultInfo = categoryService.selectCategoryAll();
        return resultInfo;
    }



    //删除种类信息
    @DeleteMapping("/delete/{categoryId}")
    public ResultInfo delete(@PathVariable Integer categoryId){
        return categoryService.deleteCategoryById(categoryId);
    }

    //修改种类信息
    @PutMapping("/updateCategory")
    public ResultInfo updateCategory(@RequestBody Category Category){
        return categoryService.updateCategory(Category);

    }

    //新增种类信息
    @PostMapping("/insertCategory")
    public ResultInfo insertCategory(@RequestBody Category Category){
        return categoryService.insertCategory(Category);
    }

    //查单个
    @GetMapping("/selectOne/{categoryId}")
    public ResultInfo selectOne(@PathVariable Integer categoryId){
        return categoryService.selectOne(categoryId);
    }
}
